package ajjj.kiviq.beans;

import java.io.Serializable;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;
import javax.faces.bean.ManagedBean;
import javax.faces.bean.ApplicationScoped;

/**
 * Used to get the current date and time
 * as a string
 * 
 * @author orjohan
 */
@ManagedBean(name = "DateBean")
@ApplicationScoped
public class DateBean implements Serializable {

    /**
     * Default constructor
     */
    public DateBean() {
    }

    /**
     * Get the current date and time, formatted
     * as YYYY-MM-DD HH:MM
     * @return The current date and time
     */
    public String getCurrentDateTime() {
        Date date = Calendar.getInstance().getTime();
        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm");
        return sdf.format(date);
    }
}
